import Vue from 'vue'
import { getAll } from '@/api/daTask'

export default class Task {
  constructor(task) {
    this.task = task
  }
  async init() {
    const ps = []
    Vue.set(this.task.task, 'da_task', {})
    Vue.set(this.task.label, 'da_task', {})
    Vue.set(this.task, 'da_task', [])
    ps.push(getAll().then(data => {
      this.task['da_task'].splice(0, 0, ...data.content)
      data.content.forEach(d => {
        Vue.set(this.task.task['da_task'], d.id, d)
        Vue.set(this.task.label['da_task'], d.id, d.serialnumber)
      })
    }))
    await Promise.all(ps)
  }
}
